/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo9282;

import java.io.File;
import java.util.HashMap;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */

public class HashMapDemo3 {
    public static void main(String args[])throws Exception{
        //ArrayList<类名> 数组名=new ArrayList<类名>();
        
        HashMap<String,String> wordMap=new HashMap<String,String>();
        File f=new File("e:/javalx/word2.txt");
        Scanner sc=new Scanner(f,"GBK"); 
        
         while(sc.hasNextLine()){
           //System.out.println(sc.next()+"    "+ sc.next());
            String s=sc.nextLine();
            String word[]=s.split(",");
             wordMap.put(word[0],word[1]);
         }
         
         HashMap<String,String> wordMap1=new HashMap<String,String>();
         for(String s:wordMap.keySet()){
             wordMap1.put(wordMap.get(s),s);
         }
         

        String word=JOptionPane.showInputDialog(null, "输入单词");
        JOptionPane.showMessageDialog(null, wordMap1.get(word));
         
         
         
      
        
      
        
        
        
        
        
                
        
        
    }
    
}
